using Autofac;
using Autofac.Features.ResolveAnything;
using uMVP;

namespace AutofacContrib.NSubstitute
{
    public class AutoSubstituteMvp<TViewClass, TPresenterInterface> : AutoSubstitute
        where TViewClass : ViewBase
        where TPresenterInterface : class, IPresenter
    {
        public AutoSubstituteMvp(params object[] parameters)
        {
            var builder = new ContainerBuilder();

            builder.RegisterSource(new AnyConcreteTypeNotAlreadyRegisteredSource());
            builder.RegisterSource(new NSubstituteMvpRegistrationSource<TViewClass, TPresenterInterface>(parameters));
            builder.RegisterSource(new NSubstituteRegistrationHandler());

            Container = builder.Build();
        }
    }
}